home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998…tember: Reference Library / Dev.CD Sep 98 RL2.toast / What's New / Software Development Kits / MacOS USB DDK / Examples / PrinterClassDriver / PrintDriverShell.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-07-20  |  4.0 KB  |  148 lines  |  [TEXT/MPS ]

  1.  
  2. /*
  3.     File:        PrintDriverShell.c
  4.  
  5.     Contains:    
  6.  
  7.     Version:    Neptune 1.0
  8.  
  9.     Copyright:    © 1997-1998 by Apple Computer, Inc., all rights reserved.
  10.  
  11.  
  12. */
  13.  
  14. #include <Types.h>
  15. #include <Devices.h>
  16. #include <DriverServices.h>
  17. #include <USB.h>
  18.  
  19. #include "PrinterClassDriver.h"
  20.  
  21. //------------------------------------------------------
  22. //
  23. // Protos
  24. //
  25. //------------------------------------------------------
  26. OSStatus printDriverValidateHW(USBDeviceRef device, USBDeviceDescriptor *desc);
  27. OSStatus printDriverInitialize(USBDeviceRef device, USBDeviceDescriptorPtr pDesc, UInt32 busPowerAvailable);
  28. OSStatus printDriverInitInterface( UInt32 interfaceNum, USBInterfaceDescriptor *interfaceDesc, USBDeviceDescriptor *deviceDesc, USBDeviceRef device);
  29. OSStatus printDriverFinalize(USBDeviceRef device, USBDeviceDescriptorPtr desc );
  30. OSStatus    printDriverNotifyProc(UInt32     notification, void *pointer);
  31.  
  32. //------------------------------------------------------
  33. //
  34. //    This is the driver description structure that the expert looks for first.
  35. //  If it's here, the information within is used to match the driver
  36. //  to the device whose descriptor was passed to the expert.
  37. //    Information in this block is also used by the expert when an
  38. //  entry is created in the Name Registry.
  39. //
  40. //------------------------------------------------------
  41. enum {
  42.     kMajorRev = 0,
  43.     kMinorAndBugRev = 0,
  44.     kStage = developStage,
  45.     kNonRelRev = 0
  46. };
  47.  
  48.  
  49. USBDriverDescription    TheUSBDriverDescription = 
  50. {
  51.     // Signature info
  52.     kTheUSBDriverDescriptionSignature,
  53.     kInitialUSBDriverDescriptor,
  54.     
  55.     // Device Info
  56.     0,                                        // vendor = not device specific
  57.     0,                                        // product = not device specific
  58.     0,                                        // version of product = not device specific
  59.     0,                                        // protocol = not device specific
  60.     
  61.     // Interface Info    (* I don't think this would always be required...*)                
  62.     0,                                        // Configuration Value
  63.     0,                                        // Interface Number
  64.     kUSBPrintClass,                    // Device Class  (from USBDeviceDefines.h)
  65.     kUSBPrintSubClass,                // Device Subclass 
  66.     0,                                        // Interface Protocol
  67.         
  68.     
  69.     // Driver Info    
  70.     "\pUSBPrint",                        // Driver name for Name Registry
  71.     kUSBPrintClass,                    // Device Class  (from USBDeviceDefines.h)
  72.     kUSBPrintSubClass,                // Device Subclass 
  73.     kMajorRev, kMinorAndBugRev, kStage, kNonRelRev,        // version of driver
  74.     
  75.     // Driver Loading Info
  76.     0x00000000                                // Flags (currently undefined)
  77. };
  78.  
  79.     
  80. USBClassDriverPluginDispatchTable TheClassDriverPluginDispatchTable =
  81. {
  82.     kClassDriverPluginVersion,            // Version of this structure
  83.     printDriverValidateHW,                // Hardware Validation Procedure
  84.     printDriverInitialize,                // Initialization Procedure
  85.     printDriverInitInterface,                // Interface Initialization Procedure
  86.     printDriverFinalize,                    // Finalization Procedure
  87.     printDriverNotifyProc,                // Driver Notification Procedure
  88. };
  89.  
  90. // Hardware Validation
  91. // Called upon load by Expert
  92. OSStatus 
  93. printDriverValidateHW(USBDeviceRef device, USBDeviceDescriptor *desc)
  94. {
  95.     device = 0;
  96.     desc = 0;
  97.     return (OSStatus)noErr;
  98. }
  99.  
  100.  
  101. // Initialization function
  102. // Called upon load by Expert
  103. OSStatus 
  104. printDriverInitialize(USBDeviceRef device, USBDeviceDescriptorPtr pDesc,
  105.                                     UInt32 busPowerAvailable)
  106. {
  107.     busPowerAvailable = 0;
  108.     
  109.     PrintDriverEntry(device, pDesc, NULL );
  110.     return (OSStatus)noErr;
  111. }
  112.  
  113. // printDriverInitInterface function
  114. // Called to initialize driver for an individual interface - either by expert or
  115. // internally by driver
  116. OSStatus
  117. printDriverInitInterface(
  118.             UInt32                         interfaceNum, 
  119.             USBInterfaceDescriptor    *interfaceDesc, 
  120.             USBDeviceDescriptor        *deviceDesc, 
  121.             USBDeviceRef                 device)
  122. {
  123.     interfaceNum = 0;
  124.  
  125.     PrintDriverEntry(device, deviceDesc, interfaceDesc );
  126.     
  127.     return (OSStatus)noErr;
  128. }
  129.  
  130. // Termination function
  131. // Called by Expert when driver is being shut down
  132. OSStatus
  133. printDriverFinalize(USBDeviceRef device, USBDeviceDescriptorPtr desc )
  134. {
  135. #pragma unused(device)
  136. #pragma unused(desc)
  137.  
  138.     return PrintDriverFinalize();
  139. }
  140.  
  141. OSStatus    
  142. printDriverNotifyProc(UInt32     notification, void *pointer)
  143. {
  144.     pointer = 0;
  145.     notification = 0;
  146.     return(noErr);
  147. }
  148.